const mongoose = require('mongoose');
const bcryptjs = require('bcryptjs');

//定义用户模型
const UserSchema = new mongoose.Schema({
    userId: { type: String },
    username: { type: String, unique: true },
    password: {
        type: String,
        set(val) {
            return bcryptjs.hashSync(val, 10);
        }
    }
    
});
const User = mongoose.model('User', UserSchema);
module.exports = User;
